<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>随手快递</title>
    <link rel="stylesheet" type="text/css" href="../../AUI/css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../font-awesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="../../myCss/control.css" type="text/css" />
    <style>
        input{
            border: 1px solid #ddd;
            border-radius: 4px;
            padding-left: 10px;
            color: #484848;
            width: 70%;
        }
        .ui-stepInfo{
            width: 80px !important;
        }
    </style>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        /*图片上传*/

        html,
        body {
            width: 100%;
            height: 100%;
        }

        .container {
            width: 100%;
            height: 100%;
            overflow: auto;
            clear: both;
        }

        .z_photo {
            width: 100%;
            height: 100%;
            padding: 0.3rem;
            overflow: auto;
            clear: both;
            margin: auto;
            background: #fff;
            border: 0px solid #555;
        }

        .z_photo img {
            width: 200px;
            height: 120px;
        }

        .z_addImg {
            float: left;
            margin-right: 0.2rem;
            margin-top: 5px;
        }

        .z_file {
            width: 60px;
            height: 60px;
            background: url(../../myImage/z_add.png) no-repeat;
            background-size: 100% 100%;
            float: left;
            margin-right: 0.2rem;
            margin-top: 5px;
        }

        .z_file input::-webkit-file-upload-button {
            width: 60px;
            height: 60px;
            border: none;
            position: absolute;
            outline: 0;
            opacity: 0;
        }

        .z_file input#file, .z_file input#file1 {
            display: block;
            width: auto;
            border: 0;
            vertical-align: middle;
        }
        /*遮罩层*/

        .z_mask {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, .5);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 999;
            display: none;
        }

        .z_alert {
            width:170px;
            height: 100px;
            border-radius: .2rem;
            background: #fff;
            font-size:15px;
            text-align: center;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }

        .z_alert p:nth-child(1) {
            line-height: 70px;
        }

        .z_alert p:nth-child(2) span {
            display: inline-block;
            width: 49%;
            height: 28px;
            line-height: 28px;
            float: left;
            border-top: 1px solid #ddd;
        }

        .z_cancel {
            border-right: 1px solid #ddd;
        }
    </style>
</head>
<body style="font-family: 微软雅黑">
<header class="aui-bar aui-bar-nav" id="aui-header">
    <a class="aui-btn aui-pull-left" tapmode onclick="history.back();">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title">快递员认证</div>
</header>
<section class="aui-content" style="margin-top: 50px">
        <div id="stepBar" class="ui-stepBar-wrap">
            <div class="ui-stepBar">
                <div class="ui-stepProcess"></div>
            </div>
            <div class="ui-stepInfo-wrap">
                <table class="ui-stepLayout" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="ui-stepInfo" style="margin-left: 30px">
                            <a class="ui-stepSequence">1</a>
                            <p class="ui-stepName">填写信息</p>
                        </td>
                        <td class="ui-stepInfo" >
                            <a class="ui-stepSequence">2</a>
                            <p class="ui-stepName">审核中</p>
                        </td>
                        <td class="ui-stepInfo">
                            <a class="ui-stepSequence">3</a>
                            <p class="ui-stepName">缴纳押金</p>
                        </td>
                        <td class="ui-stepInfo">
                            <a class="ui-stepSequence">4</a>
                            <p class="ui-stepName">认证完成</p>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
</section>
<section class="aui-content" style="margin: 10px 0 45px 0">
    <div class="aui-card-list">
        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="margin: 0 0 20px 0;font-size: 15px" ><span >真实姓名</span><span style="margin-left: 10px"><input id="name"></span></div>
            <div style="margin: 0 0 20px 0;font-size: 15px" ><span >身份证号</span><span style="margin-left: 10px"><input id="idenId"></span></div>
            <div style="margin: 0 0 20px 0;font-size: 15px" ><span >身份证正面照</span><small>(证件横向拍摄，图片内容清晰)</small>
                <div class="aui-row aui-row-padded">
                <!--    照片添加    -->
                <div class="z_photo" id="z_photo">
                    <div class="z_file" id="z_file">
                     <input type="file" id="head_file_ipt" name="file" multiple onChange="ajaxFileUpload();"  />
                        <!-- <input type="file" name="file" id="file" value="" accept="image/*"  onchange="imgChange('z_photo','z_file');" />
                     --></div>
                </div>
                <!--遮罩层-->
                <div class="z_mask">
                    <!--弹出框-->
                    <div class="z_alert">
                        <p>确定要删除这张图片吗？</p>
                        <p>
                            <span class="z_cancel">取消</span>
                            <span class="z_sure">确定</span>
                        </p>
                    </div>
                </div>
                </div>
            </div>
            <div style="margin: 0 0 10px 0;font-size: 15px" ><span >身份证背面照</span><small>(证件横向拍摄，图片内容清晰)</small>
                <div class="aui-row aui-row-padded">
                <!--    照片添加    -->
                <div class="z_photo" id="z_photo1">
                    <div class="z_file" id="z_file1">
                     <input type="file" id="head_file_ipt1" name="file" multiple onChange="ajaxFileUpload1();"  />
                        <!-- <input type="file" name="file" id="file1" value="" accept="image/*"  onchange="imgChange1('z_photo','z_file');" />
                    --> </div>
                </div>
                <!--遮罩层-->
                <div class="z_mask">
                    <!--弹出框-->
                    <div class="z_alert">
                        <p>确定要删除这张图片吗？</p>
                        <p>
                            <span class="z_cancel">取消</span>
                            <span class="z_sure">确定</span>
                        </p>
                    </div>
                </div>
            </div>
            </div>
        </div>
    </div>
</section>

<section class="aui-bar aui-bar-tab" >
        <div class="aui-btn aui-btn-success aui-btn-block aui-btn-outlined aui-btn-sm" tapmode onclick="identf()">去审核</div>
</section>
<script type="text/javascript" src="../../AUI/script/api.js" ></script>
<script src="../../myJs/jquery.js"></script>
<script src="../../myJs/ajaxfileupload.js"></script>
<script src="../../myJs/jquery.cookie.js"></script>
<script type="text/javascript" src="../../myJs/index.js" ></script>
<script type="text/javascript" src="../../myJs/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="../../myJs/stepBar.js"></script>
<script type="text/javascript">
    $(function(){
        stepBar.init("stepBar", {
            step : 1,
            change : true,
            animation : true
        });

    });
    
    var idCardUp,idCardDown;
    function ajaxFileUpload() {
        /* var files = document.getElementById("head_file_ipt").files;
          for(var i=0; i< files.length; i++){
              alert(head_file_ipt.files[i].name);
          }*/
                $.ajaxFileUpload({
                    url : '/randomdelivery/userManageController/imageUpload', //用于文件上传的服务器端请求地址
                    secureuri : false, //是否需要安全协议，一般设置为false
                    fileElementId : 'head_file_ipt', //文件上传域的ID
                    dataType : 'json', //返回值类型 一般设置为json
                    contentType:'x-www-form-urlencoded',
                    success : function(data) { //服务器成功响应处理函数
                        alert(JSON.stringify(data));
                        idCardUp=data.msg.headUrl;
                        $("#z_photo").append('<img src="'+data.msg.headUrl+'">');
                    },
                    error : function(data, status, e) { //服务器响应失败处理函数
                        alert(JSON.stringify(data));
                        alert(status);
                        alert(e);
                    }
                });
      }
    
    function ajaxFileUpload1() {
        /* var files = document.getElementById("head_file_ipt").files;
          for(var i=0; i< files.length; i++){
              alert(head_file_ipt.files[i].name);
          }*/
                $.ajaxFileUpload({
                    url : '/randomdelivery/userManageController/imageUpload', //用于文件上传的服务器端请求地址
                    secureuri : false, //是否需要安全协议，一般设置为false
                    fileElementId : 'head_file_ipt1', //文件上传域的ID
                    dataType : 'json', //返回值类型 一般设置为json
                    contentType:'x-www-form-urlencoded',
                    success : function(data) { //服务器成功响应处理函数
                        alert(JSON.stringify(data));
                        idCardDown=data.msg.headUrl;
                        $("#z_photo1").append('<img src="'+data.msg.headUrl+'">');
                        
                    },
                    error : function(data, status, e) { //服务器响应失败处理函数
                        alert(JSON.stringify(data));
                        alert(status);
                        alert(e);
                    }
                });
      }

    function identf(){


        var name = $("#name").val();
        if(name==""){
            alertmd("请输入真实姓名");
            return false;
        }
        var idenId = $("#idenId").val();
        if(idenId==""){
            alertmd("请输入身份证号");
            return false;
        }
        if (!idenId.match(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/)) {
            alertmd("身份证号格式不正确");
            $("#idenId").val("");
            return false;
        }
        var userId = sessionStorage.getItem("userId");
        
       alert(idCardDown);
         $.ajax({
         type: "post",
         url: '/randomdelivery/userCourierManageController/requestAuditCourier',
         data: {
         "readName": name,
         "idCardNo": idenId,
         "idCardUp": idCardUp,
         "idCardDown": idCardDown
         },
         datatype: "json",
         success: function (data) {
        	 location.href='identification2.html';
         }

         });
        
    }
    apiready = function(){
        api.parseTapmode();
    }
    //px转换为rem
    (function(doc, win) {
        var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function() {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    if (clientWidth >= 640) {
                        docEl.style.fontSize = '100px';
                    } else {
                        docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
                    }
                };

        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
    })(document, window);

    function imgChange(obj1, obj2) {
        //获取点击的文本框
        var file = document.getElementById("file");
        var z_file = document.getElementById("z_file");
        //存放图片的父级元素
        var imgContainer = document.getElementsByClassName(obj1)[0];
        //获取的图片文件
        var fileList = file.files;
        //文本框的父级元素
        var input = document.getElementsByClassName(obj2)[0];
        var imgArr = [];
        //遍历获取到得图片文件
        for (var i = 0; i < fileList.length; i++) {
            alert(file.files[i].url);
            alert(file.files[i].type);
            var imgUrl = window.URL.createObjectURL(file.files[i]);
            imgArr.push(imgUrl);
            var img = document.createElement("img");
            img.setAttribute("src", imgArr[i]);
            var imgAdd = document.createElement("div");
            imgAdd.setAttribute("class", "z_addImg");
            imgAdd.appendChild(img);
            imgContainer.insertBefore(imgAdd,z_file);
        };
        imgRemove();
    };
    function imgChange1(obj1, obj2) {
        //获取点击的文本框
        var file = document.getElementById("file1");
        var z_file = document.getElementById("z_file1");
        //存放图片的父级元素
        var imgContainer = document.getElementById("z_photo1");
        //获取的图片文件
        var fileList = file.files;
        //文本框的父级元素
        var input = document.getElementById("z_file1");
        var imgArr = [];
        //遍历获取到得图片文件
        for (var i = 0; i < fileList.length; i++) {
            var imgUrl = window.URL.createObjectURL(file.files[i]);
            imgArr.push(imgUrl);
            var img = document.createElement("img");
            img.setAttribute("src", imgArr[i]);
            var imgAdd = document.createElement("div");
            imgAdd.setAttribute("class", "z_addImg");
            imgAdd.appendChild(img);
            imgContainer.insertBefore(imgAdd,z_file);
        };
        imgRemove();
    };
    function imgRemove() {
        var imgList = document.getElementsByClassName("z_addImg");
        var mask = document.getElementsByClassName("z_mask")[0];
        var cancel = document.getElementsByClassName("z_cancel")[0];
        var sure = document.getElementsByClassName("z_sure")[0];
        for (var j = 0; j < imgList.length; j++) {
            imgList[j].index = j;
            imgList[j].onclick = function() {
                var t = this;
                mask.style.display = "block";
                cancel.onclick = function() {
                    mask.style.display = "none";
                };
                sure.onclick = function() {
                    mask.style.display = "none";
                    t.style.display = "none";
                };

            }
        };
    };
</script>
</body>
</html>